cmake_minimum_required(VERSION 3.14)
project(ukui-nvpanel)
set(VERSION_MAJOR 1)
set(VERSION_MINOR 0)
set(VERSION_MICRO 0)
set(UKUI_NVPANEL_VERSION ${VERSION_MAJOR}.${VERSION_MINOR}.${VERSION_MICRO})

set(CMAKE_CXX_STANDARD 17)
set(CMAKE_INCLUDE_CURRENT_DIR ON)
set(CMAKE_AUTOMOC ON)
set(CMAKE_AUTORCC ON)
set(CMAKE_CXX_STANDARD_REQUIRED ON)

find_package(QT NAMES Qt6 Qt5 COMPONENTS Core Gui Widgets Quick REQUIRED)
find_package(Qt${QT_VERSION_MAJOR} COMPONENTS Core Gui Widgets Quick REQUIRED)
find_package(CUDAToolkit REQUIRED)


set(PROJECT_SOURCES
    plugin/ukui-nvpanel-plugin.h
    plugin/ukui-nvpanel-plugin.cpp
    plugin/nvpanel.h
    plugin/nvpanel.cpp
)

set(UKUI_NVPANEL_DATA_DIR "/usr/share/ukui/widgets/org.ukui.nvpanel")
set(UKUI_NVPANEL_TRANSLATION_DIR "${UKUI_DIGITALCLOCK_DATA_DIR}/translations")

qt5_add_resources(QRC_FILES plugin/res.qrc)

if(${QT_VERSION_MAJOR} GREATER_EQUAL 6)
    add_library(${PROJECT_NAME} SHARED MANUAL_FINALIZATION ${PROJECT_SOURCES} ${QRC_FILES})
else()
    add_library(${PROJECT_NAME} SHARED ${PROJECT_SOURCES} ${QRC_FILES})
endif()

target_compile_definitions(${PROJECT_NAME}
        PRIVATE $<$<OR:$<CONFIG:Debug>>:QT_QML_DEBUG>
)

target_link_libraries(${PROJECT_NAME}
    PRIVATE
    Qt${QT_VERSION_MAJOR}::Core
    Qt${QT_VERSION_MAJOR}::Quick
    Qt${QT_MAJOR_VERSION}::Gui
    Qt${QT_VERSION_MAJOR}::Widgets
    CUDA::nvml
)




install(DIRECTORY "widget/" DESTINATION ${UKUI_NVPANEL_DATA_DIR})
install(FILES "plugin/qmldir" DESTINATION "/usr/lib/${CMAKE_LIBRARY_ARCHITECTURE}/qt5/qml/org/ukui/nvpanel")
install(TARGETS ${PROJECT_NAME} LIBRARY DESTINATION  "/usr/lib/${CMAKE_LIBRARY_ARCHITECTURE}/qt5/qml/org/ukui/nvpanel")
